1. Technical Field
The present invention relates to the file caching and more particularly to an enhanced fragment cache configured to cache page fragments whose contents vary depending upon one or more variables.
2. Description of the Related Art
Recently, information technologists have become concerned with the overall scalability of their information technology infrastructure. Notwithstanding, when investigating the causes for concern at typical business-to-consumer sites, it has been discovered that information technologists generally remain satisfied with the scalability of their core business logic executing on large, back-end computing systems. Rather, the concerns of information technologists typically are focused on the presentation layer of network deployed applications.
Importantly, the presentation layer is the focus of concern because the presentation layer can be considered a fairly new part of the information technology infrastructure. Also, the presentation layer often must handle a steadily growing demand for data in the form of network requests. Finally, the presentation layer must accommodate increasingly more complex presentation logic. Still, back-end servers hosting back-end application logic and data, by comparison, technically are more sophisticated than those systems hosting the presentation layer and, in consequence, back-end servers tend to accommodate growth more easily. Furthermore, traffic on the back-end servers tends not to increase as sharply as traffic on the front-end systems since not every network request leads to a business transaction which must be processed in the back-end servers. As a result, recent application server innovations focus on methods and systems for enhancing the performance and scalability of the presentation layer. More particularly, caching algorithms often are utilized to assist in this endeavor.
One such application server, the Websphere(trademark) application server manufactured by International Business Machines Corporation of Armonk, N.Y., incorporates an advanced caching system referred to as a xe2x80x9cdynamic fragment cachexe2x80x9d which enables caching of partial Web pages. By caching partial Web pages, the page fragment cache avoids the overhead of re-executing portions of the presentation logic on subsequent network requests. Advantageously, unlike conventional page caches, the dynamic fragment cache can selectively cache and refresh fragments of a page rather than the entire pages. Hence, the dynamic fragment cache more efficiently utilizes the resources of its host.
Nevertheless, the dynamic fragment cache in certain circumstances can fall short of providing the degree of flexibility that is required by many network sites serving dynamic content. Specifically, in the Web application server environment, fragments produced dynamically by scripts, servlets and the like often change their output depending upon the different variables utilized by the script or servlet during its execution. Often, only the value of one or more of these variables differs between different executions of a fragment. Notably, in the dynamic fragment cache of the Websphere environment, when the dynamic fragment cache caches the output of different executions fo the same page fragment, the page fragment must be executed for each combination of input variables. In consequence, a fragment cache entry must be created for each of the multiple page fragments, though the multiple page fragments differ only in the value of one or more of these variables.
The present invention addresses the deficiencies of the prior art by providing a method and system for enhanced fragment caching in which only a single cache entry is written for page fragments which differ only in their evaluation of a variable object when producing dynamic content. Specifically, a method for enhanced fragment caching can include identifying in at least one of first and second retrieved page fragments a variable object utilized by the fragment upon execution to produce dynamic content. Separate cache entries can be written for the first and second retrieved page fragments where the first and second retrieved page fragments differ in ways other than an evaluation of the variable object. Otherwise, a single cache entry can be written for both the first and second retrieved page fragments where the first and second retrieved page fragments differ only in the evaluation of the variable object.
The enhanced fragment cache of the present invention can include one or more cache entries, at least a portion of which can store static content associated with a corresponding page fragment; and, at least one variable place holder in one of the cache entries, the variable place holder storing a reference to a variable object utilized by the corresponding page fragment upon execution to produce dynamic content. The enhanced fragment cache of the present invention also can include an applications programming interface (API) having one or more user-accessible functions for interacting with and configuring the enhanced fragment cache. The user-accessible functions, in turn, can include at least one user-accessible function for directing the enhanced fragment cache to store a reference to a variable object in a variable place holder in a cache entry.
In one particular aspect of the present invention, the method for enhanced fragment caching can include identifying in a first retrieved page fragment a variable object utilized by the first page fragment upon execution to produce dynamic content. While static portions of the first page fragment can be stored in a cache entry, importantly, a placeholder can be further stored in the cache entry for the variable object. Notably, both the static portions of the first page fragment stored in the cache entry, and also the associated dynamic content produced by evaluating the variable object, can be served from the cache entry.
In addition to the first page fragment, an additional page fragment can be retrieved and another variable object can be identified therein, wherein the variable object can be utilized by the additional page fragment upon execution to produce dynamic content. It can be determined whether the additional page fragment differs from the first page fragment only in the evaluation of the variable objects. In consequence, static portions of the additional page fragment can be stored in a subsequent cache entry only if the additional page fragment differs from the first page fragment in ways other than the evaluation of the variable objects.
In a second aspect of the present invention, a method for enhanced fragment caching can include programming a page fragment to produce dynamic content based upon values for one or more variable objects; configuring the page fragment with a fragment cache instruction to store references to one or more variable objects in corresponding variable place holders in a cache entry in a fragment cache; and, deploying the configured and programmed page fragment in a content server associated with the fragment cache.